package com.apexwear.apexutils.data;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.apex.bluetooth.callback.GeneralCallback;
import com.apex.bluetooth.callback.MonitorReminderCallback;
import com.apex.bluetooth.core.EABleManager;
import com.apex.bluetooth.enumeration.QueryWatchInfoType;
import com.apex.bluetooth.model.EABleMonitorReminder;

public class ReminderData extends ViewModel {
    public MutableLiveData<Boolean> setReminder(EABleMonitorReminder eaBleMonitorReminder) {
        MutableLiveData<Boolean> mutableLiveData = new MutableLiveData<>();
        EABleManager.getInstance().addMonitorReminder(eaBleMonitorReminder, new GeneralCallback() {
            @Override
            public void result(boolean b,int i) {
                mutableLiveData.postValue(b);
            }

            @Override
            public void mutualFail(int i) {
                mutableLiveData.postValue(false);
            }
        });
        return mutableLiveData;
    }

    public MutableLiveData<EABleMonitorReminder> getReminder() {
        MutableLiveData<EABleMonitorReminder> mutableLiveData = new MutableLiveData<>();
        EABleManager.getInstance().queryWatchInfo(QueryWatchInfoType.monitor_reminder, new MonitorReminderCallback() {
            @Override
            public void monitorReminder(EABleMonitorReminder eaBleMonitorReminder) {
                mutableLiveData.postValue(eaBleMonitorReminder);
            }

            @Override
            public void mutualFail(int i) {
                mutableLiveData.postValue(null);
            }
        });
        return mutableLiveData;
    }
}
